<?php
/*
	区域代理中心
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$return['pluginset']=$this->plugin_setting('setting');
if($_RQ['op']=='main'){
	$_SESSION['forward_url']='jy_area_psi/index/';
	$return['setting']=$this->plugin_setting('page');
	set_html('title',$return['setting']['center']);
	model('jy_weishop/member')->checklogin();
	$member=$this->get('member',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	$agent_area=$this->model('member')->check_area($member);
	$level_id=$agent_area['level_id'];
	$get_levels=$this->model('model')->get_levels(true);
	$member['leveltitle']=$get_levels[$level_id];
	$member['leveltitle']=$member['leveltitle']?:'默认等级';
	$basic=model('core/member')->basic($_SESSION['uid']);
	$member=array_merge($member,$basic);
	$return['member']=$member;
	$data=array();
	//已结算佣金
	$data['balance_total']=$this->sum('balance',array('mid'=>$_SESSION['uid']),'money');
	$data['balance_num']=$this->count('balance',array('mid'=>$_SESSION['uid']));
	//待结算佣金
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'status'=>1);
	$data['order_num']=$this->count('commission',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'id');
	/*if($this->setting['balance_day']){
		//结算天数
		$time=TIMESTAMP-intval($this->setting['balance_day'])*86400;
		$params['complete_time <']=$time;
	}*/
	$data['commission_1']=$this->sum('commission',$params,'money');
	$data['commission_total']=$this->sum('commission',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'level <'=>18),'money');
	$data['commission_count']=$this->count('commission',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'level <'=>18));
	if($agent_area['is_duodai']){
		$duodai=str_array($agent_area['duodai']);
		$data['area_num']=count($duodai);
	}else{
		$data['area_num']=$this->count('agent_area',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	}
	$data['commission_xuni']=$this->sum('commission',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'level'=>18),'money');
	$return['data']=$data;
	$return['item']=$agent_area;
	$return['xuniname']=$this->xuniname;
	exi($return);
}

?>